import { Table, Button, Space } from 'antd';

// 定义供应商数据类型
type Supplier = {
  supplier_id: number;
  company_name: string;
  credit_code: string;
  legal_representative: string;
  registered_address: string;
  contact_number: string;
  email: string;
  business_license: string;
  production_license: string;
  quality_management_certification: string;
  id: number; // 用于 Table 的 rowKey
};

// 虚拟数据
const dataSource: Supplier[] = [
  {
    supplier_id: 1,
    company_name: '供应商 A',
    credit_code: '123456789012345678',
    legal_representative: '张三',
    registered_address: '北京市朝阳区',
    contact_number: '13800138000',
    email: 'supplierA@example.com',
    business_license: '',
    production_license: '',
    quality_management_certification: '',
    id: 1,
  },
  {
    supplier_id: 2,
    company_name: '供应商 B',
    credit_code: '234567890123456789',
    legal_representative: '李四',
    registered_address: '上海市浦东新区',
    contact_number: '13900139000',
    email: 'supplierB@example.com',
    business_license: '',
    production_license: '',
    quality_management_certification: '',
    id: 2,
  },
];

export default function SupplierList() {
  const columns = [
    {
      title: '供应商 ID',
      dataIndex: 'supplier_id',
    },
    {
      title: '企业名称',
      dataIndex: 'company_name',
    },
    {
      title: '统一社会信用代码',
      dataIndex: 'credit_code',
    },
    {
      title: '法定代表人',
      dataIndex: 'legal_representative',
    },
    {
      title: '注册地址',
      dataIndex: 'registered_address',
    },
    {
      title: '联系电话',
      dataIndex: 'contact_number',
    },
    {
      title: '电子邮箱',
      dataIndex: 'email',
    },
    {
      title: '营业执照',
      dataIndex: 'business_license',
    },
    {
      title: '生产许可证',
      dataIndex: 'production_license',
    },
    {
      title: '质量管理体系认证证书',
      dataIndex: 'quality_management_certification',
    },
    {
      title: '操作',
      render: () => (
        <Space>
          <Button type="link">详情</Button>
          <Button type="link">评估</Button>
        </Space>
      ),
    },
  ];

  return (
    <div style={{ padding: 24 }}>
      <Button type="primary" style={{ marginBottom: 16 }}>新增供应商</Button>
      <Table columns={columns} dataSource={dataSource} rowKey="id" size="small" />
    </div>
  );
}